package com.example.service;

import com.example.entity.Account;
import com.example.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LogoutService {

    @Autowired
    private RedisUtils redisUtils;

    /**
     * 注销当前用户，删除其Redis中的token
     * @param account
     */
    public void handleLogout(Account account) {
        // 构造Redis中的key
        String redisKey = "TOKEN_" + account.getUsername();
        
        // 删除该用户在Redis中的token
        redisUtils.remove(redisKey);
    }
}
